#pragma once

#include <Ogre.h>
#include "BtOgrePG.h"
#include "BtOgreGP.h"
#include "BtOgreExtras.h"
#include "DefaultCube.h"
enum CannonSide
{
	Cannon_Side_Right,
	Cannon_Side_Left,
};

class BaseCannon
{
public:
	BaseCannon(Ogre::String name, Ogre::SceneManager* sceneMgr, Ogre::SceneNode* parentNode, Ogre::Vector3 pPos, int side);
	~BaseCannon(void);

	void rotateLeft();
	void rotateRight();
	void updateCannon(double timeSinceLastFrame);
	void updateTarget(Ogre::Vector3 target);
	void fireCannon();
	void changeDebugVisibility();

	Ogre::SceneNode*			m_CannonNode;
	Ogre::SceneNode*			m_CannonBaseNode;
	Ogre::SceneNode*			m_ParentNode;
	Ogre::SceneManager*			m_pSceneMgr;

private:

	bool isCollision();

	Ogre::Entity*				m_CannonEntity;
	Ogre::Vector3				m_TranslateVector;
	Ogre::Vector3				m_RotateVector;
	Ogre::Real					m_MoveSpeed;
	Ogre::Real					m_RotateSpeed;
	float						m_MoveScale;
	float						m_RotScale;

	Ogre::Timer*				cannonTimer;
	Ogre::Vector3				m_CannonTarget;
	int							m_CannonSide;

	bool						canFire;
	float						canFireDelay;
	Ogre::ManualObject *			    circle;
	Ogre::ManualObject *			    line;
	Ogre::Entity*				m_LineEntity;
	Ogre::SceneNode*			m_FireLineNode;
	DefaultRectangle*			m_FireLineCube;
	Ogre::Real					rotProgress;
	Ogre::Real					m_RotationMin;
	Ogre::Real					m_RotationMax; 
	Ogre::Real					m_RotationDef;
};

